package com.mdd.admin.vo.coupon;

import com.mdd.common.utils.TimeUtil;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;

@Data
public class CouponListVo implements Serializable {
    private static final long serialVersionUID = 1L;

    private Integer id;        // 主键
    private String name;       //优惠券名称
    private String content;    //优惠内容
    private BigDecimal amount; //优惠金额
    private Integer promotionMethod;  //推广方式 0 = 系统发放 1 = 用户领取
    private String promotionMethodDesc;
    private Integer number;  //发放数量
    private Integer isUsed;    //是否使用过 1=是 0=否
    private Integer usageRate; //使用率
    private String usageRateDesc;
    private Integer status; //优惠券状态 0 = 未开始 1 = 进行中 2 = 已结束
    private String statusDesc;
    private Integer editBtn;  //编辑按钮 0 = 不可编辑  1 = 可编辑
    private Integer deleteBtn; //删除按钮 0 = 不可删除  1 = 可删除
    private String usedTime; //使用时间
    private String createTime; // 创建时间
    private String updateTime;// 修改时间
    private Long startTime; // 开始时间
    private Long endTime; // 结束时间

    private Integer isSuperimposing;  // 是否叠加   0-不叠加使用  1-叠加使用
    private Integer shareType;  // 分享类型  0-不分享   1-二维码分享   2-兑换码分享
    private String imageAddress; // 图片地址

    public void setUsageRateDesc(Integer usageRate){
        this.usageRateDesc = usageRate + "%";
    }

    public void setPromotionMethodDesc(Integer promotionMethod){
        switch (promotionMethod){
            case 0:
                this.promotionMethodDesc = "系统发放";
                break;
            case 1:
                this.promotionMethodDesc = "用户领取";
        }
    }

    public void setStatusDesc(Integer status){
        switch (status){
            case 0:
                this.statusDesc = "未开始";
                break;
            case 1:
                this.statusDesc = "进行中";
                break;
            case 2:
                this.statusDesc = "已结束";
        }
    }

    public void setEditBtn(Integer status){
        switch (status){
            case 0:
            case 1:
                this.editBtn = 1;
                break;
            case 2:
                this.editBtn = 0;
        }
    }

    public void setDeleteBtn(Integer status){
        switch (status){
            case 0:
            case 2:
                this.deleteBtn = 1;
                break;
            case 1:
                this.deleteBtn = 0;
        }
    }

    public void setUsedTime(Long startTime, Long endTime){
        this.usedTime = TimeUtil.timestampToDate(startTime) + "-" + TimeUtil.timestampToDate(endTime);
    }
}
